package cc.coolplay51.fakashop3.Config;

import feign.codec.Encoder;
import feign.form.FormEncoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;



/**
 * @Classname FeignConfig
 * @Description TODO
 * @Date 2021/5/1 1:43
 * @Created by HanYuHao
 */
@Configuration
public class FeignConfig {

    @Autowired
    private ObjectFactory<HttpMessageConverters> messageConverters;

    //Feign表单提交配置
    @Bean
    @Primary
    @Scope(BeanDefinition.SCOPE_PROTOTYPE)
    Encoder formEncoder() {
        return new FormEncoder(new SpringEncoder(this.messageConverters));
    }
}
